package tron.controller;

import org.springframework.web.bind.annotation.*;
import tron.dto.Parameters;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class TronRestController {

    @GetMapping("/getString")
    public String getString() {
        return "it`s a string";
    }

    @GetMapping("/getParameter")
    public Map<String, Object> getParameters( String a, Integer b, Boolean c) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("string", a);
        hashMap.put("integer", b);
        hashMap.put("boolean", c);
        return hashMap;
    }

    @GetMapping("/getListParameters")
    public Map<String, Object> getListParameters(@RequestParam List<String> list) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("list", list);
        return hashMap;
    }

    @GetMapping("/getMapParameters")
    public Map<String, Object> getMapParameters(@RequestParam Map<String, Object> map) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("map", map);
        return hashMap;
    }

    @PostMapping("/postParameters")
    public Map<String, Object> postParameters(String a, Integer b) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("string", a);
        hashMap.put("integer", b);
        return hashMap;
    }

    @PostMapping("/postListParameters")
    public Map<String, Object> postListParameters(@RequestBody Parameters parameters) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("list", parameters);
        return hashMap;
    }

    @PostMapping("/postListParameters1")
    public Map<String, Object> postListParameters1(@RequestBody Map map) {
        return map;
    }
}
